<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}


$page = !($_POST['pageNum'])?'1':intval($_POST['pageNum']);
$pagesize= !($_POST['numPerPage'])?'20':intval($_POST['numPerPage']);

$sday=trim($_REQUEST["sday"]);
$eday=trim($_REQUEST["eday"]);
if(empty($sday)){
    $sday=date("Y-m-d",time()-3600*24*60);
}
if(empty($eday)){
    $eday=date("Y-m-d");
}


if(empty($pagesize)){
    $pagesize=20;
}
$frmnum=($page-1)*$pagesize;
$orderField=trim($_POST["orderField"]);
$orderDirection=trim($_POST["orderDirection"]);
if(empty($orderField)){
    $orderField="ctime";
}
if(empty($orderDirection)){
    $orderDirection="desc";
}
if($orderField<>""){
    $order=" order by $orderField ".$orderDirection;
}else{
    $order=" order by ctime desc";
}

$id=empty($_REQUEST['id'])?0:(int)$_REQUEST['id'];
if(empty($id)){

    error_html("没有找到食材ID！","","");
}

$where="mid=".$id;

if(!empty($sday) or !empty($eday)){
    
    $where.=" and ctime>='".$sday." 00:00:00' and ctime<='".$eday." 23:59:59'";
}

$total=$ezhand->count("datamet_items",$where);
$caigou_items=$ezhand->select_all("datamet_items",'*',''.$where.' '.$order.' limit '.$frmnum.','.$pagesize);





?>